class DL_LottoModel {
  /*
  "id": 370,
            "lottery_name": "DEAR TOUCAN SUNDAY WEEKLY LOTTERY",
            "lottery_type": "8PM",
            "draw_date": "2024-12-22",
            "first_prize": 10000000,
            "second_prize": 9000,
            "third_prize": 450,
            "forth_prize": 250,
            "fifth_prize": 120,
            "sixth_prize": 0,
            "seventh_prize": 0,
            "eighth_prize": 0,
            "first_prize_num": "52B52542",
            "second_prize_num": "20329,33300,42376,53625,54464,68002,79691,94480,96760,98469",
            "third_prize_num": "3743,3851,4518,5904,5981,7993,8963,9618,9675,9685",
            "fourth_prize_num": "0276,3289,3749,3929,4676,6027,6706,7502,8861,9927",
            "fifth_prize_num": "0207,2100,3967,4990,5805,6697,7207,7925,8694,9500,0316,2129,4009,5011,5813,6739,7334,8001,8924,9539,0506,2708,4063,5052,5896,6762,7465,8297,9007,9577,0599,2905,4072,5178,5901,6786,7467,8325,9029,9625,0833,3075,4127,5231,6293,6809,7477,8388,9188,9655,1170,3433,4238,5284,6461,6834,7625,8444,9253,9676,1226,3438,4318,5389,6522,6888,7628,8487,9295,9696,1401,3457,4515,5729,6578,6921,7769,8548,9303,9752,1817,3538,4566,5756,6590,7047,7794,8584,9305,9908,1897,3558,4722,5760,6659,7091,7910,8693,9412,9945",
            "sixth_prize_num": "",
            "seventh_prize_num": "",
            "eighth_prize_num": "",
            "image_url": "",
            "created_at": "2024-12-25 07:57:50",
            "updated_at": "2025-01-06 16:39:04"
  */

  int? id;
  String? lottery_name;
  String? lottery_type;
  String? draw_date;
  int? first_prize;
  int? second_prize;
  int? third_prize;
  int? forth_prize;
  int? fifth_prize;
  int? sixth_prize;
  int? seventh_prize;
  int? eighth_prize;
  List? first_prize_num;
  List? second_prize_num;
  List? third_prize_num;
  List? forth_prize_num;
  List? fifth_prize_num;
  List? sixth_prize_num;
  List? seventh_prize_num;
  List? eighth_prize_num;
  List? all_prize_num;
  String? image_url;
  String? created_at;
  String? updated_at;

  DL_LottoModel({
    this.id,
    this.lottery_name,
    this.lottery_type,
    this.draw_date,
    this.first_prize,
    this.second_prize,
    this.third_prize,
    this.forth_prize,
    this.fifth_prize,
    this.sixth_prize,
    this.seventh_prize,
    this.eighth_prize,
    this.first_prize_num,
    this.second_prize_num,
    this.third_prize_num,
    this.forth_prize_num,
    this.fifth_prize_num,
    this.sixth_prize_num,
    this.seventh_prize_num,
    this.eighth_prize_num,
    this.all_prize_num,
    this.image_url,
    this.created_at,
    this.updated_at,
  });

  DL_LottoModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    lottery_name = lottoNameWith(json['lottery_name'] ?? '');
    lottery_type = json['lottery_type'];
    draw_date = json['draw_date'];
    first_prize = json['first_prize'];
    second_prize = json['second_prize'];
    third_prize = json['third_prize'];
    forth_prize = json['forth_prize'];
    fifth_prize = json['fifth_prize'];
    sixth_prize = json['sixth_prize'];
    seventh_prize = json['seventh_prize'];
    eighth_prize = json['eighth_prize'];
    first_prize_num = prizeStringToList(json['first_prize_num'] ?? '');
    second_prize_num = prizeStringToList(json['second_prize_num'] ?? '');
    third_prize_num = prizeStringToList(json['third_prize_num'] ?? '');
    forth_prize_num = prizeStringToList(json['forth_prize_num'] ?? '');
    fifth_prize_num = prizeStringToList(json['fifth_prize_num'] ?? '');
    sixth_prize_num = prizeStringToList(json['sixth_prize_num'] ?? '');
    seventh_prize_num = prizeStringToList(json['seventh_prize_num'] ?? '');
    eighth_prize_num = prizeStringToList(json['eighth_prize_num'] ?? '');
    all_prize_num = allPrizes();
    image_url = json['image_url'];
    created_at = json['created_at'];
    updated_at = json['updated_at'];
  }

  lottoNameWith(String name) {
    // 将字符串按空格分割成单词
    List<String> words = name.split(' ');

    String lottoName = '';
    // 保留第二和第三个单词
    if (words.length >= 3) {
      String secondWord = words[1];
      String thirdWord = words[2];

      return lottoName = '$secondWord $thirdWord';
    } else {
      return lottoName;
    }
  }

  prizeStringToList(String prizeString) {
    List<String> stringArray = [];
    if (prizeString.isEmpty) {
      return [];
    }
    stringArray = prizeString.split(',');
    return stringArray;
  }

  allPrizes() {
    var allPrizes = [];
    if (first_prize_num!.isNotEmpty) {
      Map firstPrize = {
        'title': '1st Prize',
        'numbers': first_prize_num,
        'prizeAmount': first_prize.toString(),
      };
      allPrizes.add(firstPrize);
    }

    if (second_prize_num!.isNotEmpty) {
      Map secondPrize = {
        'title': '2nd Prize',
        'numbers': second_prize_num,
        'prizeAmount': second_prize.toString(),
      };
      allPrizes.add(secondPrize);
    }

    if (third_prize_num!.isNotEmpty) {
      Map thirdPrize = {
        'title': '3rd Prize',
        'numbers': third_prize_num,
        'prizeAmount': third_prize.toString(),
      };
      allPrizes.add(thirdPrize);
    }

    if (forth_prize_num!.isNotEmpty) {
      Map forthPrize = {
        'title': '4th Prize',
        'numbers': forth_prize_num,
        'prizeAmount': forth_prize.toString(),
      };
      allPrizes.add(forthPrize);
    }

    if (fifth_prize_num!.isNotEmpty) {
      Map fifthPrize = {
        'title': '5th Prize',
        'numbers': fifth_prize_num,
        'prizeAmount': fifth_prize.toString(),
      };
      allPrizes.add(fifthPrize);
    }

    if (sixth_prize_num!.isNotEmpty) {
      Map sixthPrize = {
        'title': '6th Prize',
        'numbers': sixth_prize_num,
        'prizeAmount': sixth_prize.toString(),
      };
      allPrizes.add(sixthPrize);
    }

    if (seventh_prize_num!.isNotEmpty) {
      Map seventhPrize = {
        'title': '7th Prize',
        'numbers': seventh_prize_num,
        'prizeAmount': seventh_prize.toString(),
      };
      allPrizes.add(seventhPrize);
    }

    if (eighth_prize_num!.isNotEmpty) {
      Map eighthPrize = {
        'title': '8th Prize',
        'numbers': eighth_prize_num,
        'prizeAmount': eighth_prize.toString(),
      };
      allPrizes.add(eighthPrize);
    }
    return allPrizes;
  }
}

class DL_NextDrawModel {
  /*
  "playable": true,
        "playable_text": "BUY\nTICKET",
        "link": "https://api.lotteries.guru/index.php/Lottery/go?lotto=india-dear-lottery",
        "lottery_name": "Mahanadi Thursday",
        "draw_timestamp": 1736407800000,
        "seconds_until_draw": 24256,
        "istTimeString": "1PM, Thu, Jan 09, 2025",
        "lottery_type": "1PM"
  */

  bool? playable;
  String? playable_text;
  String? link;
  String? lottery_name;
  int? draw_timestamp;
  int? seconds_until_draw;
  String? istTimeString;
  String? lottery_type;

  DL_NextDrawModel({
    this.playable,
    this.playable_text,
    this.link,
    this.lottery_name,
    this.draw_timestamp,
    this.seconds_until_draw,
    this.istTimeString,
    this.lottery_type,
  });

  DL_NextDrawModel.fromJson(Map<String, dynamic> json) {
    playable = json['playable'];
    playable_text = json['playable_text'];
    link = json['link'];
    lottery_name = json['lottery_name'];
    draw_timestamp = json['draw_timestamp'];
    seconds_until_draw = json['seconds_until_draw'];
    istTimeString = json['istTimeString'];
    lottery_type = json['lottery_type'];
  }
}
